﻿package frEngine.util
{
    import flash.geom.*;
    import flash.utils.*;
    import frEngine.loaders.particleSub.*;

    public class HelpUtils extends Object
    {
        private static const idMap:Dictionary = new Dictionary(false);
        private static var _id:uint = 0;
        private static var _randomMap:Dictionary = new Dictionary(false);

        public function HelpUtils()
        {
            return;
        }// end function

        public static function getSortIdByName(param1:String) : int
        {
            var _loc_2:* = idMap[param1];
            if (_loc_2 == 0)
            {
                _loc_2 = _id + 1;
                idMap[param1] = _id + 1;
            }
            return _loc_2;
        }// end function

        public static function getRandomArr(param1:uint, param2:uint, param3:uint) : Array
        {
            var _loc_4:* = String(param1) + ":" + param3;
            var _loc_5:* = _randomMap[_loc_4];
            if (!_loc_5)
            {
                if (param1 == 0)
                {
                    var _loc_6:* = new ParticleRandomObject(param1);
                    _randomMap[_loc_4] = new ParticleRandomObject(param1);
                    _loc_5 = _loc_6;
                }
                else
                {
                    var _loc_6:* = new ParticleRandomObject(param1 + param3);
                    _randomMap[_loc_4] = new ParticleRandomObject(param1 + param3);
                    _loc_5 = _loc_6;
                }
            }
            if (_loc_5.randomArr.length < param2)
            {
                _loc_5.reInitMaxLen(param2);
            }
            return _loc_5.randomArr;
        }// end function

        public static function convetIntColorToV3D(param1:int) : Vector3D
        {
            var _loc_2:* = new Vector3D();
            var _loc_3:* = param1 % 256;
            var _loc_4:* = (param1 >> 8) % 256;
            var _loc_5:* = (param1 >> 16) % 256;
            _loc_2.x = Math.max(0, Math.min(_loc_5 / 256, 1));
            _loc_2.y = Math.max(0, Math.min(_loc_4 / 256, 1));
            _loc_2.z = Math.max(0, Math.min(_loc_3 / 256, 1));
            _loc_2.w = 1;
            return _loc_2;
        }// end function

    }
}
